<html>
<head><meta charset="utf-8"><title>future incompat lint emit · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html">future incompat lint emit</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232415198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232415198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232415198">(Mar 30 2021 at 12:19)</a>:</h4>
<p>How do I emit a future incompatibility lint with only access to the <code>Session</code>?</p>



<a name="232415552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232415552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232415552">(Mar 30 2021 at 12:22)</a>:</h4>
<p>I'm confused what Session has to do with it - isn't future compatibility a property of the lint itself? You could look at <a href="https://github.com/rust-lang/rust/blob/689e8470ffa7aeca17cfee428704a4d6c4148c11/compiler/rustc_lint_defs/src/builtin.rs#L42">https://github.com/rust-lang/rust/blob/689e8470ffa7aeca17cfee428704a4d6c4148c11/compiler/rustc_lint_defs/src/builtin.rs#L42</a> for an example</p>



<a name="232415659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232415659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232415659">(Mar 30 2021 at 12:23)</a>:</h4>
<p>I mean I have a future incompat lint defined. Now I want to emit a warning diagnostic for said lint.</p>



<a name="232415716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232415716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232415716">(Mar 30 2021 at 12:24)</a>:</h4>
<p>oh, you can emit it like any normal lint</p>



<a name="232415772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232415772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232415772">(Mar 30 2021 at 12:24)</a>:</h4>
<p>though it's indeed not as simple as emitting a lint from a LateContext</p>



<a name="232415773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232415773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232415773">(Mar 30 2021 at 12:24)</a>:</h4>
<p><code>buffer_lint</code> is not a method on <code>Session</code>. Only on <code>LintBuffer</code> and <code>ParseSess</code>.</p>



<a name="232415781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232415781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232415781">(Mar 30 2021 at 12:24)</a>:</h4>
<p>you don't need to buffer</p>



<a name="232415797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232415797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232415797">(Mar 30 2021 at 12:25)</a>:</h4>
<p>sec, looking for the correct function</p>



<a name="232415804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232415804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232415804">(Mar 30 2021 at 12:25)</a>:</h4>
<p>I just used it two days ago</p>



<a name="232415869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232415869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232415869">(Mar 30 2021 at 12:25)</a>:</h4>
<p><code>struct_span_lint_hir</code></p>



<a name="232415957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232415957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232415957">(Mar 30 2021 at 12:26)</a>:</h4>
<p>it's on <code>tcx</code> oh</p>



<a name="232415972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232415972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232415972">(Mar 30 2021 at 12:26)</a>:</h4>
<p>This is before HIR is available.</p>



<a name="232416097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232416097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232416097">(Mar 30 2021 at 12:27)</a>:</h4>
<p>Basically there is a function that runs before the regular parsing and only parses the input source file to get a specific attribute. I want to deprecate this attribute.</p>



<a name="232416237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232416237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232416237">(Mar 30 2021 at 12:28)</a>:</h4>
<p>you can get at the <code>ParseSess</code> via a <code>Session</code>, then you can use buffering from there</p>



<a name="232416429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232416429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232416429">(Mar 30 2021 at 12:30)</a>:</h4>
<p>Thanks, that worked.</p>



<a name="232416467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232416467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232416467">(Mar 30 2021 at 12:30)</a>:</h4>
<p>just out of curiosity, why aren't you using a plain pre-expansion lint or similar?</p>



<a name="232416723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232416723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232416723">(Mar 30 2021 at 12:32)</a>:</h4>
<p>I never used pre-expansion lints.</p>



<a name="232416753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232416753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232416753">(Mar 30 2021 at 12:32)</a>:</h4>
<p>Where should I place it then?</p>



<a name="232416768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232416768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232416768">(Mar 30 2021 at 12:32)</a>:</h4>
<p>like early lints, just before macro expansion. For your case even a regular early lint would work I'd think?</p>



<a name="232416856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232416856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232416856">(Mar 30 2021 at 12:33)</a>:</h4>
<p>Yeah, the attributes are inert, so early lints should work.</p>



<a name="232416883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232416883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232416883">(Mar 30 2021 at 12:33)</a>:</h4>
<p>there is a <code>register_internals</code> function in <code>rustc_lint</code> where you can add new lints</p>



<a name="232417014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232417014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232417014">(Mar 30 2021 at 12:34)</a>:</h4>
<p>thogh... that's the wrong thing. <code>register_builtins</code> is the one you want</p>



<a name="232417032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/future%20incompat%20lint%20emit/near/232417032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/future.20incompat.20lint.20emit.html#232417032">(Mar 30 2021 at 12:34)</a>:</h4>
<p>you aren't linting rustc, you are lintijng regular code</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>